<?php

namespace app\api\controller;

use app\common\controller\IndexBase;
use app\common\helper\AuthHelper;

class Archives extends IndexBase
{
    // 课程详情
    public function getDetail()
    {
        if ($this->request->isPost()) {
            $id = input('id/d');
            $info = (new \app\common\model\Archives())->find($id);
            $this->success($info);
        }
    }
    
    // 课程列表
    public function getList()
    {
        $category_id = input("category_id/d");
        $where = [];
        if ($category_id) {
            $where[] = ['category_id', '=', $category_id];
        }
        $list = \app\common\model\Archives::getList($this->page, $this->limit, $where);
        $token = AuthHelper::getToken();
        $is_huo = \app\common\model\Category::getCategoryIdsByUser($token,$category_id);
        $this->success([
            "is_huo" => $is_huo,
            "list" => $list
        ]);
    }
}